from tools_algorithm import *


class Solution:
    def maxSelectedElements(self, nums: List[int]) -> int:
        ans = 0
        # [2, 3, 6, 8, 9, 10, 10, 11, 12, 12, 13, 16, 18, 19]
        nums.sort()
        h = Counter()
        for v in nums:
            h[v + 1] = h.get(v, 0) + 1
            h[v] = h.get(v - 1, 0) + 1
            ans = max(ans, h[v], h[v + 1])
        return ans


s = Solution()
print(s.maxSelectedElements([2, 3, 6, 8, 9, 10, 10, 11, 12, 12, 13, 16, 18, 19]))

import os

print(os.path.dirname(__file__))
file = open(f"{os.path.dirname(__file__)}/1.txt", "w", encoding="utf-8")
for _ in range(1):
    a = []
    for _ in range(100000):
        a.append(random.randint(1, 1000000))
    print(a, file=file)
